package designMode.iteratorPattern;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author LIBOFEI
 * @ClassName Test
 * @description
 * @date 2020/6/26 16:22
 * @Version 1.0
 **/
public class Test {

    public static void main(String[] args) {

        /** *
         未使用迭代器模式前   打印菜单的某一项,必须循环所有的菜单，集合和数组
        **/
        PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
        List<MenuItem> menuItemList =  pancakeHouseMenu.getMenuItems();

        DinnerHouseMenu dinnerHouseMenu = new DinnerHouseMenu();
        MenuItem[] menuItemsArray = dinnerHouseMenu.getMenuItems();
        CafeMenu cafeMennu = new CafeMenu();
        cafeMennu.addItem("name","1111",false,1);

        for(MenuItem m : menuItemList){
            System.out.println((((((((((((m.toString()))))))))))));
        }
        for(MenuItem m : menuItemsArray){
            System.out.println(m.toString());
        }

        System.out.println("---------------------------------");

        /***
         * 使用迭代器后
        **/
        List<MenuIterator> list = new ArrayList<>();
        list.add(pancakeHouseMenu);
        list.add(dinnerHouseMenu);
        list.add(cafeMennu);
//        Print print = new Print(pancakeHouseMenu,dinnerHouseMenu,cafeMennu);
        Print print = new Print(list);
        print.printAllMenu();
    }
}
